/*
 * JTableTester.java - Test application for TableSorter and related classes
 *
 * Copyright (c) 2004-2008 Gregory Kotsaftis
 * gregkotsaftis@yahoo.com
 * http://zeus-jscl.sourceforge.net/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
package gr.zeus.tests;

import gr.zeus.ui.table.AutoResizeTableColumns;
import gr.zeus.ui.table.ProgressBarCellRenderer;
import gr.zeus.ui.table.TableSorter;
import gr.zeus.ui.table.TableSorterIcons;
import gr.zeus.util.DateHelper;
import it.allerj.common.i18n.StaticString;
import it.allerj.gui.MainJFrame;
import it.allerj.gui.css.CSS;
import it.allerj.gui.images.ImageReferenceResource;
import it.allerj.model.AllergicElement;
import it.allerj.model.AllergicTest;
import it.allerj.model.AllergicTestSingleFrame;
import it.allerj.model.Frame;
import it.allerj.model.Patient;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Hashtable;
import java.util.List;
import java.util.ResourceBundle;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.SpinnerNumberModel;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

public class JTableSupport extends JFrame {
    
   
    private static final String[] COLUMN_NAMES = getDemoColumn();
    
    private static final Object[][] values = getDemoData();
    // THIS IS YOUR TABLE MODEL!
    private DefaultTableModel m_tableModel = getNewTableModelForResults(COLUMN_NAMES);
    public static String[] getPatientColumn() {
         return new String[]{CSS.rs.getString("i18n.edit"), CSS.rs.getString("i18n.name.patient"), CSS.rs.getString("i18n.surname.patient"), CSS.rs.getString("i18n.tel.patient"),CSS.rs.getString("i18n.mobile.patient"), CSS.rs.getString("i18n.birthdate.patient")};
     }
    public static String[] getResultColumn() {
         return new String[]{CSS.rs.getString("i18n.edit"), CSS.rs.getString("i18n.date.at"), CSS.rs.getString("i18n.barcode.reagent.at"), CSS.rs.getString("i18n.single.at"),CSS.rs.getString("i18n.positive.at")};
     }
    
     public static String[] getFrameColumn() {
         return new String[]{CSS.rs.getString("i18n.test"), CSS.rs.getString("i18n.value")};
     }
     public static Object[][] getTestData(List<AllergicElement> allergicElementList){
        Object[][] values = new Object[allergicElementList.size()][2];

         //Toolkit.getDefaultToolkit().getImage(url)
       
         // Create an action with an icon

        for(int i = 0; i<allergicElementList.size(); i++){
            final AllergicElement allergicElement = allergicElementList.get(i);

            try{
                values[i][0]= CSS.rs.getString(allergicElement.getType());
                values[i][1]= ""+allergicElement.getValue();

            } catch (Exception e) {e.printStackTrace();
                values = new Object[0][0];
            }
        }
        return values;
    }
    public static Object[][] getPatientData(List<Patient> patientList, final MainJFrame mainJFrame, boolean editPatient){
        Object[][] values = new Object[patientList.size()][6];
         //Patient patient = null;
         //Toolkit.getDefaultToolkit().getImage(url)
        String urlIcon = (editPatient)?"Zoom16.gif":"checkmrk.gif";
         Icon icon = new ImageIcon(ImageReferenceResource.class.getResource(urlIcon));
         // Create an action with an icon
        
        for(int i = 0; i<patientList.size(); i++){
            final Patient patient = patientList.get(i);
            final Action action;
            if(editPatient){
                 action = new AbstractAction("", icon) {
                    public void actionPerformed(ActionEvent e) {

                        mainJFrame.setModel(patient);
                        mainJFrame.bindingPatientToEditPanel();

                        GridBagConstraints c = new GridBagConstraints();
                        c.fill = java.awt.GridBagConstraints.BOTH;
                        c.gridx = 0;
                        c.gridy = 0;
                        c.weightx = 1.0;
                        c.weighty = 0.65;
                        mainJFrame.innerEditPatient.add(mainJFrame.analysisStep2Body, c);

                        c = new GridBagConstraints();
                        c.fill = GridBagConstraints.BOTH;
                        c.gridx = 0;
                        c.gridy = 1;
                        c.weightx = 1.0;
                        c.weighty = 0.35;
                        mainJFrame.innerEditPatient.add(mainJFrame.dataTablePanel1, c);

                        mainJFrame.patientPane.remove(mainJFrame.searchPatientPanel);
                        mainJFrame.patientPane.add(mainJFrame.editPatient);

                        mainJFrame.repaint();
                        mainJFrame.pack();

                    }
                };
            } else {
                action = new AbstractAction("", icon) {
                    public void actionPerformed(ActionEvent e) {

                        mainJFrame.setModel(patient);
                        mainJFrame.analysisPane.remove(mainJFrame.analysisStep2);
                        mainJFrame.analysisPane.add(mainJFrame.analysisStep3);
                        mainJFrame.repaint();
                        mainJFrame.pack();  

                    }
                };
            }
            
            final JButton button = new JButton();
           button.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseReleased(java.awt.event.MouseEvent evt) {
                    button.setAction(action);
                }
            });
                

            button.setIcon(icon);
            try{

                values[i][0]= button;
                values[i][1]= patient.getName();
                values[i][2]= patient.getSurname();
                values[i][3]= patient.getMobile();
                values[i][4]= patient.getTelephone();
                values[i][5]= patient.getBirthDate();


            } catch (Exception e) {
                values = new Object[0][0];
            }
        }
        return values;
    }
    public static Object[][] getResultData(List<AllergicTest> allergicTestList, final MainJFrame mainJFrame){
        Object[][] values = new Object[allergicTestList.size()][6];
         //Patient patient = null;
         //Toolkit.getDefaultToolkit().getImage(url)
         Icon icon = new ImageIcon(ImageReferenceResource.class.getResource("Zoom16.gif"));
         // Create an action with an icon
        
        for(int i = 0; i<allergicTestList.size(); i++){
            final AllergicTest allergicTest = allergicTestList.get(i);
            final Action action = new AbstractAction("", icon) {
                public void actionPerformed(ActionEvent e) {
                   
                    
                    mainJFrame.bindingAllergicTestToshowPanel(allergicTest);
                    
                  /*  GridBagConstraints c = new GridBagConstraints();
                    c.fill = java.awt.GridBagConstraints.BOTH;
                    c.gridx = 0;
                    c.gridy = 0;
                    c.weightx = 1.0;
                    c.weighty = 0.65;
                    mainJFrame.innerEditPatient.add(mainJFrame.analysisStep2Body, c);
                    
                    c = new GridBagConstraints();
                    c.fill = GridBagConstraints.BOTH;
                    c.gridx = 0;
                    c.gridy = 1;
                    c.weightx = 1.0;
                    c.weighty = 0.35;
                    mainJFrame.innerEditPatient.add(mainJFrame.dataTablePanel1, c);*/
                    
 
                    mainJFrame.resultPane.remove(mainJFrame.searchResultPanel);
                    mainJFrame.resultPane.add(mainJFrame.showResultPanel);
                 
                    mainJFrame.repaint();
                    mainJFrame.pack();
                    
                }
            };
            
            final JButton button = new JButton();
           button.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseReleased(java.awt.event.MouseEvent evt) {
                    button.setAction(action);
                }
            });
                

            button.setIcon(icon);
            try{

                values[i][0]= button;
                values[i][1]= allergicTest.getDate();
                values[i][2]= allergicTest.getReagentBarcode();
                values[i][3]= (allergicTest instanceof AllergicTestSingleFrame);
                boolean positive = false;
                for(Frame frame : allergicTest.getFrameList()){
                    positive = (frame.getAllergicElementList().size()>0);
                    if(positive)
                        break;
                }
                values[i][4] = positive;


            } catch (Exception e) {
                values = new Object[0][0];
                e.printStackTrace();
            }
        }
        return values;
    }
    public static void setProgressBarModelOnColumn(JTable table, int column){
         // TABLE SPECIAL RENDERER FOR PROGRESSBAR
        // configuration for progress bar...
        Hashtable<Integer,Color> limitColors = new Hashtable<Integer,Color>();
        limitColors.put(new Integer( 0), Color.green);
        limitColors.put(new Integer(60), Color.yellow);
        limitColors.put(new Integer(80), Color.red);
       
        // COLUMN 6 contains progress bar!
        TableColumnModel model = table.getColumnModel();
        model.getColumn(column).setCellRenderer( new ProgressBarCellRenderer(
                true, false, 0, 100, limitColors, table.getBackground()) );
        //-----
        
    }
    public static DefaultTableModel getNewTableModelForResults(String[] COLUMN_NAMES){
        return new DefaultTableModel(null, COLUMN_NAMES) {
        
            public boolean isCellEditable(int row, int column)
            {
                if(getValueAt(0, column) instanceof JButton){
                    return true;
                }
                return( false );
            }

            public Class getColumnClass(int column)
            {
                return( getValueAt(0, column).getClass() );
            }
        };
        
    }
     public static DefaultTableModel getNewTableModelForTests(String[] COLUMN_NAMES){
        return new DefaultTableModel(null, COLUMN_NAMES) {
        
            public boolean isCellEditable(int row, int column)
            {
                
                return( false );
            }

            public Class getColumnClass(int column)
            {
                return( getValueAt(0, column).getClass() );
            }
        };
        
    }
     public static void setSizeForIconButton(JTable table, int columnIndex){
        TableColumn col = table.getColumnModel().getColumn(columnIndex);
        int width = 40;
        col.setPreferredWidth(width);
        col.setMaxWidth(width);
        col.setMinWidth(width);
    }
    
    public static TableSorter getNewTableSorter(DefaultTableModel tableModel, JTable table){
        TableSorter tableSorter = new TableSorter(tableModel);
        Icon ups[] = new Icon[] {
                TableSorterIcons.UP5_ICON, // this one will be dispayed first
                TableSorterIcons.UP7_ICON,
                TableSorterIcons.UP6_ICON,
                TableSorterIcons.UP4_ICON,
                TableSorterIcons.UP3_ICON,
                TableSorterIcons.UP2_ICON,
                TableSorterIcons.UP1_ICON
        };
        Icon downs[] = new Icon[] {
                TableSorterIcons.DOWN5_ICON, // this one will be dispayed first
                TableSorterIcons.DOWN7_ICON,
                TableSorterIcons.DOWN6_ICON,
                TableSorterIcons.DOWN4_ICON,
                TableSorterIcons.DOWN3_ICON,
                TableSorterIcons.DOWN2_ICON,
                TableSorterIcons.DOWN1_ICON
        };
        tableSorter.setCustomIcons(ups, downs);
        tableSorter.setTableHeader(table.getTableHeader());
        return tableSorter;
    }
    public static AutoResizeTableColumns getNewResizer(DefaultTableModel tableModel, JTable table){
        return new AutoResizeTableColumns(table, 
            tableModel, 32, true, true, 
                new boolean[table.getColumnCount()]);
    }
    
    public JTableSupport()
    {
        initComponents();
        
        
        // set the table model
        m_table.setModel( m_tableModel );
        
        // no reordering of the columns
        //m_table.getTableHeader().setReorderingAllowed( false );
        
        // select only one row
        //m_table.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
        
        // use scrollbar
        //m_table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
        
        // Hiding first column in order to test resize
        //GUIUtils.hideJTableColumn( m_table.getColumnModel().getColumn(0) );
        
        // SORTING CONFIGURATION
        // if you wish to use the same icons regardless of column's sorting 
        // priority, then use the two lines below.
        //
        //Icon ups[] = new Icon[] {TableSorterIcons.UP5_ICON};
        //Icon downs[] = new Icon[] {TableSorterIcons.DOWN5_ICON};
        //
        
        /*
         ALE COMMENT
         Icon ups[] = new Icon[] {
                TableSorterIcons.UP5_ICON, // this one will be dispayed first
                TableSorterIcons.UP7_ICON,
                TableSorterIcons.UP6_ICON,
                TableSorterIcons.UP4_ICON,
                TableSorterIcons.UP3_ICON,
                TableSorterIcons.UP2_ICON,
                TableSorterIcons.UP1_ICON
        };
        Icon downs[] = new Icon[] {
                TableSorterIcons.DOWN5_ICON, // this one will be dispayed first
                TableSorterIcons.DOWN7_ICON,
                TableSorterIcons.DOWN6_ICON,
                TableSorterIcons.DOWN4_ICON,
                TableSorterIcons.DOWN3_ICON,
                TableSorterIcons.DOWN2_ICON,
                TableSorterIcons.DOWN1_ICON
        };
        m_tableSorter.setCustomIcons(ups, downs);
        m_tableSorter.setTableHeader( m_table.getTableHeader() );
        */
        // THIS IS A VIEW OF YOYR ACTUAL TABLE MODEL, USED FOR TABLE SORTING!
        TableSorter m_tableSorter = getNewTableSorter(m_tableModel, m_table);
        m_table.setModel( m_tableSorter );
        //-----
        
        // TABLE RESIZING CONFIGURATION
        // resize but don't lock the columns
        
        /*
         ALE COMMENT
         AutoResizeTableColumns resizer = new AutoResizeTableColumns(m_table, 
            m_tableModel, 32, true, true, 
                new boolean[m_table.getColumnCount()]);
        */
        getNewResizer(m_tableModel, m_table);
        // uncomment for debuging
        //resizer.setDebugMode( true );
        //-----
        
        // TABLE ACTUAL DATA
        try
        {
            /*
             * ALE COMMENT
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            Object[][] values = new Object[][]
            {
                {sdf.parse("29/11/2004"), new Integer(999), 
                         "Gregory", "Kotsaftis", new Float(999.99F), 
                         Boolean.FALSE, new Integer(90)},
                {sdf.parse("14/06/2003"), new Integer(888), 
                         "Litsa", "Katsoni", new Float(888.88F), 
                         Boolean.TRUE, new Integer(80)},
                {sdf.parse("20/07/2001"), new Integer(9), 
                         "George", "Mavrakis", new Float(109.30F), 
                         Boolean.TRUE, new Integer(25)},
                {sdf.parse("30/10/1999"), new Integer(190), 
                         "Kostas", "Filippaios", new Float(23.27F), 
                         Boolean.FALSE, new Integer(50)},
                {sdf.parse("02/02/2002"), new Integer(1258), 
                         "John", "Papadopoulos", new Float(109.30F), 
                         Boolean.TRUE, new Integer(100)},
                {sdf.parse("15/12/1985"), new Integer(910), 
                         "Spyros", "Papadolpoulos", new Float(410.08F), 
                         Boolean.FALSE, new Integer(75)},
                {sdf.parse("6/04/2000"), new Integer(5), 
                         "Makis", "Triantafyllopoulos", new Float(10.00F), 
                         Boolean.TRUE, new Integer(100)}
            };
             * */
            
            /* instead of addRow()... */
            /*m_tableModel.addRow(values[0]);
            m_tableModel.addRow(values[1]);
            m_tableModel.addRow(values[2]);
            m_tableModel.addRow(values[3]);
            m_tableModel.addRow(values[4]);
            m_tableModel.addRow(values[5]);
            m_tableModel.addRow(values[6]);*/
            
            /* ...use setDataVector() for performance! */
            m_tableModel.setDataVector(values, COLUMN_NAMES);
            //-----
        }
        catch(Exception e)
        {
            e.printStackTrace();            
        }
         setProgressBarModelOnColumn(m_table, 6);
       
    }
    
    
    /**
     * Quick and dirty data entry to table.
     */
    private void add_row()
    {
        try
        {
            java.util.Date d = DateHelper.parseDate(
                                dateTextField.getText().trim(), "dd/MM/yyyy");
            Integer i = new Integer( intTextField.getText().trim() );
            String firstname = firstnameTextField.getText().trim();
            String lastname = lastnameTextField.getText().trim();
            Float f = new Float( floatTextField.getText().trim() );
            Boolean b = new Boolean( checkBox.isSelected() );
            Integer percent = (Integer) percentSpinner.getValue();
            
            m_tableModel.addRow( new Object[]{d, i, firstname, lastname, f, b, 
                                                percent} );
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
        m_table = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        dateTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        intTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        firstnameTextField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        lastnameTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        floatTextField = new javax.swing.JTextField();
        checkBox = new javax.swing.JCheckBox();
        jLabel6 = new javax.swing.JLabel();
        percentSpinner = new JSpinner(
            new SpinnerNumberModel(0, 0, 100, 10)  );
        button = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Tester for JTable sorting, resizing and more...");

        m_table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4", "Title 5", "Title 6", "Title 7"
            }
        ));
        m_table.setToolTipText("Press down and hold CTRL or SHIFT while selecting multiple columns' headers for sorting.");
        jScrollPane1.setViewportView(m_table);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel1.setMinimumSize(new java.awt.Dimension(500, 60));
        jPanel1.setPreferredSize(new java.awt.Dimension(500, 60));
        jPanel1.setLayout(null);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("dd/MM/yyyy");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(10, 10, 70, 20);
        jPanel1.add(dateTextField);
        dateTextField.setBounds(10, 30, 70, 22);

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("int");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(90, 10, 30, 20);
        jPanel1.add(intTextField);
        intTextField.setBounds(90, 30, 30, 22);

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("firstname");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(130, 10, 90, 20);
        jPanel1.add(firstnameTextField);
        firstnameTextField.setBounds(130, 30, 90, 22);

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("lastname");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(230, 10, 90, 20);
        jPanel1.add(lastnameTextField);
        lastnameTextField.setBounds(230, 30, 90, 22);

        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("float");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(330, 10, 30, 20);
        jPanel1.add(floatTextField);
        floatTextField.setBounds(330, 30, 30, 22);
        jPanel1.add(checkBox);
        checkBox.setBounds(370, 30, 20, 25);

        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText("percent");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(400, 10, 40, 20);
        jPanel1.add(percentSpinner);
        percentSpinner.setBounds(400, 30, 40, 22);

        button.setText("+");
        button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonActionPerformed(evt);
            }
        });
        jPanel1.add(button);
        button.setBounds(450, 10, 40, 40);

        getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_buttonActionPerformed
    {//GEN-HEADEREND:event_buttonActionPerformed
        
        add_row();
        
    }//GEN-LAST:event_buttonActionPerformed
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[])
    {
        try
        {
            UIManager.setLookAndFeel( 
                    UIManager.getSystemLookAndFeelClassName() );
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
        
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JTableSupport().setVisible(true);
            }
        });
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton button;
    private javax.swing.JCheckBox checkBox;
    private javax.swing.JTextField dateTextField;
    private javax.swing.JTextField firstnameTextField;
    private javax.swing.JTextField floatTextField;
    private javax.swing.JTextField intTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField lastnameTextField;
    private javax.swing.JTable m_table;
    private javax.swing.JSpinner percentSpinner;
    // End of variables declaration//GEN-END:variables
 public static String[] getDemoColumn() {
         return new String[]{"DATE","INTEGER","FIRSTNAME","LASTNAME","FLOAT","BOOLEAN","PROGRESS"};
     }
     public static String[] getMyDemoColumn() {
         return new String[]{"DATE","INTEGER","FIRSTNAME","LASTNAME","FLOAT","BOOLEAN","PROGRESS", "BUTTON"};
     }
    public static Object[][] getDemoData() {
        Object[][] values = null;
        try{
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            values = new Object[][]
                {
                    {sdf.parse("29/11/2004"), new Integer(999), 
                             "Gregory", "Kotsaftis", new Float(999.99F), 
                             Boolean.FALSE, new Integer(90)},
                    {sdf.parse("14/06/2003"), new Integer(888), 
                             "Litsa", "Katsoni", new Float(888.88F), 
                             Boolean.TRUE, new Integer(80)},
                    {sdf.parse("20/07/2001"), new Integer(9), 
                             "George", "Mavrakis", new Float(109.30F), 
                             Boolean.TRUE, new Integer(25)},
                    {sdf.parse("30/10/1999"), new Integer(190), 
                             "Kostas", "Filippaios", new Float(23.27F), 
                             Boolean.FALSE, new Integer(50)},
                    {sdf.parse("02/02/2002"), new Integer(1258), 
                             "John", "Papadopoulos", new Float(109.30F), 
                             Boolean.TRUE, new Integer(100)},
                    {sdf.parse("15/12/1985"), new Integer(910), 
                             "Spyros", "Papadolpoulos", new Float(410.08F), 
                             Boolean.FALSE, new Integer(75)},
                    {sdf.parse("6/04/2000"), new Integer(5), 
                             "Makis", "Triantafyllopoulos", new Float(10.00F), 
                             Boolean.TRUE, new Integer(100)}
                };
        } catch (Exception e) {
            values = new Object[0][0];
        }
        return values;
            
    }
    
    public static Object[][] getMyDemoData() {
        Object[][] values = null;
        try{
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            values = new Object[][]
                {
                    {sdf.parse("29/11/2004"), new Integer(999), 
                             "Gregory", "Kotsaftis", new Float(999.99F), 
                             Boolean.FALSE, new Integer(90),new JButton("CIAO1")},
                    {sdf.parse("14/06/2003"), new Integer(888), 
                             "Litsa", "Katsoni", new Float(888.88F), 
                             Boolean.TRUE, new Integer(100), new JButton("CIAO2")},
                    {sdf.parse("20/07/2001"), new Integer(9), 
                             "George", "Mavrakis", new Float(109.30F), 
                             Boolean.TRUE, new Integer(0),new JButton("CIAO3")},
                    {sdf.parse("30/10/1999"), new Integer(190), 
                             "Kostas", "Filippaios", new Float(23.27F), 
                             Boolean.FALSE, new Integer(1),new JButton("CIAO4")},
                    {sdf.parse("02/02/2002"), new Integer(1258), 
                             "John", "Papadopoulos", new Float(109.30F), 
                             Boolean.TRUE, new Integer(75),new JButton("CIAO5")},
                    {sdf.parse("15/12/1985"), new Integer(910), 
                             "Spyros", "Papadolpoulos", new Float(410.08F), 
                             Boolean.FALSE, new Integer(45),new JButton("CIAO6")},
                    {sdf.parse("6/04/2000"), new Integer(5), 
                             "Makis", "Triantafyllopoulos", new Float(10.00F), 
                             Boolean.TRUE, new Integer(50),new JButton("CIAO7")}
                };
        } catch (Exception e) {
            values = new Object[0][0];
        }
        return values;
            
    }   
}
